app.controller('shansongCtrl',['$scope','$http','adBuy',"$stateParams",'count',
function($scope,$http,adBuy,$stateParams,count){
	$scope.text = '热销榜';
	$scope.fun1=function($event){
		var $div = angular.element($event.target);
		$div.parent().parent().find('div').removeClass('active');
		$div.addClass('active');
		request($div.text());
	}
	
	
	function request(text){
		$http({
			method: "GET",
			url:"http://h5.yztctech.net/api/axf/apicategory.php",
			params: {
				category: text
			}
		}).success(function(data){
			$scope.data = data.data;
			$scope.text = text;
//		console.log($scope.text)
		})
	}
	request($stateParams.text||'热销榜');
	$scope.fun2 = function(i,num){
		if(!i.num){
			i.num=1;
		} else if(i.num){
			i.num += num;	
		}
		adBuy.addCar(i,$scope.text);
		count.countFn();
		
	}
	
	
	
	
}])
